package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.LiveLikeDTO;
import com.yxw.live_vod_boot.dto.LiveLikeNumberQueryDTO;
import com.yxw.live_vod_boot.service.LiveLikeService;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;


@RestController
@Api(value = "直播点赞管理", tags = "直播点赞管理")
@Slf4j
@RequestMapping("/api/live/like")
public class LiveLikeController {

    @Autowired
    private LiveLikeService liveLikeService;

    /**
     * 直播点赞
     */
    @ApiOperation(value = "直播点赞")
    @PostMapping(value = "/doLiveLike")
    public BaseResult doLiveLike(@RequestBody @Validated LiveLikeDTO dto) {
        liveLikeService.doLiveLike(dto);
        return BaseResult.doSuccess(null, "操作成功");
    }

    /**
     * 查询当前直播总点赞量
     */
    @ApiOperation(value = "查询当前直播总点赞量")
    @PostMapping(value = "/getLiveLikeInfo")
    public BaseResult getLiveLikeInfo(@RequestBody @Validated LiveLikeNumberQueryDTO dto) {
        return liveLikeService.getLiveLikeInfo(dto.getLiveId());
    }

    /**
     * 点赞信息从redis添加到数据库
     */
    @ApiOperation(value = "点赞信息从redis添加到数据库")
    @PostMapping(value = "/addLikeRecord")
    public BaseResult addLikeRecord() {
        liveLikeService.addLikeRecord();
        return BaseResult.doSuccess(null, "执行成功");
    }
}